package com.sina.weibo;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.sina.weibo.models.CommentMessage;
import com.sina.weibo.models.MBlog;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

public class SinaWeiboDB extends SQLiteOpenHelper
{
  public static final int AT = 2;
  public static final int COMMENT = 3;
  public static final String COMMENT_CONTENT = "commentcontent";
  public static final String COMMENT_ID = "commentid";
  public static final String COMMENT_MBLOG_CONTENT = "mblogcontent";
  public static final String COMMENT_MBLOG_ID = "mblogid";
  public static final String COMMENT_MBLOG_NICK = "mblognick";
  public static final String COMMENT_MBLOG_UID = "mbloguid";
  private static final String COMMENT_MESSAGE_TABLE = "comment_message_table";
  public static final String COMMENT_NICK = "commentnick";
  public static final String COMMENT_NUM = "commentnum";
  public static final String COMMENT_PORTRAIT = "commentportrait";
  public static final String COMMENT_SRC_CONTENT = "srccontent";
  public static final String COMMENT_SRC_ID = "srcid";
  public static final String COMMENT_SRC_NICK = "srcnick";
  public static final String COMMENT_SRC_UID = "srcuid";
  public static final String COMMENT_TIME = "commenttime";
  public static final String COMMENT_UID = "commentuid";
  public static final String CONTENT = "content";
  public static final String DATE = "time";
  private static final String DB_NAME = "sina_weibo";
  public static final String FAV_ID = "favid";
  public static final int HOME = 0;
  private static final String HOME_TABLE = "home_table";
  public static final String IS_VIP = "vip";
  public static final String MBLOG_FROM = "src";
  public static final String MBLOG_ID = "mblogid";
  public static final int MESSAGE = 1;
  public static final String NICK_NAME = "nick";
  public static final String PIC_URL = "pic";
  public static final String PORTRAIT_URL = "portrait";
  public static final String RTROOT_ID = "rtrootid";
  public static final String RTROOT_NICK = "rtrootnick";
  public static final String RTROOT_UID = "rtrootuid";
  public static final String RTROOT_VIP = "rtrootvip";
  public static final String RT_NUM = "rtnum";
  public static final String RT_REASON = "rtreason";
  public static final String UID = "uid";
  private static final int Version = 2;
  private static SinaWeiboDB mWeiboDB = null;

  private SinaWeiboDB(Context paramContext)
  {
    super(paramContext, "sina_weibo", null, 2);
  }

  public static SinaWeiboDB getInstance(Context paramContext)
  {
    if (mWeiboDB == null)
      mWeiboDB = new SinaWeiboDB(paramContext);
    return mWeiboDB;
  }

  public boolean delete(String paramString, int paramInt)
  {
    SQLiteDatabase localSQLiteDatabase = getWritableDatabase();
    switch (paramInt)
    {
    default:
    case 0:
    }
    for (int i = 0; ; i = 1)
    {
      return i;
      String str = "DELETE FROM home_table WHERE MBLOG_ID = " + paramString;
      localSQLiteDatabase.execSQL(str);
    }
  }

  public boolean deleteAll(int paramInt)
  {
    int i = 1;
    SQLiteDatabase localSQLiteDatabase = getWritableDatabase();
    switch (paramInt)
    {
    case 1:
    case 2:
    default:
      i = 0;
    case 0:
    case 3:
    }
    while (true)
    {
      return i;
      try
      {
        localSQLiteDatabase.execSQL("DELETE FROM home_table");
      }
      catch (SQLException localSQLException)
      {
        i = 0;
      }
      continue;
    }
  }

  public boolean insert(List<?> paramList, int paramInt)
  {
    SQLiteDatabase localSQLiteDatabase = getWritableDatabase();
    switch (paramInt)
    {
    case 1:
    case 2:
    default:
    case 0:
    case 3:
    }
    while (true)
    {
      int i = 1;
      return i;
      Iterator localIterator1 = paramList.iterator();
      label50: if (!localIterator1.hasNext())
        continue;
      MBlog localMBlog = (MBlog)localIterator1.next();
      ContentValues localContentValues1 = new ContentValues();
      String str1 = localMBlog.mblogid;
      localContentValues1.put("mblogid", str1);
      String str2 = localMBlog.uid;
      localContentValues1.put("uid", str2);
      String str3 = localMBlog.favid;
      localContentValues1.put("favid", str3);
      String str4 = localMBlog.nick;
      localContentValues1.put("nick", str4);
      String str5 = localMBlog.portrait;
      localContentValues1.put("portrait", str5);
      String str6 = "vip";
      if (localMBlog.vip)
      {
        str7 = "1";
        label177: localContentValues1.put(str6, str7);
        String str8 = localMBlog.content;
        localContentValues1.put("content", str8);
        String str9 = localMBlog.rtrootuid;
        localContentValues1.put("rtrootuid", str9);
        String str10 = localMBlog.rtrootnick;
        localContentValues1.put("rtrootnick", str10);
        str6 = "rtrootvip";
        if (!localMBlog.rtrootvip)
          break label413;
      }
      label413: for (String str7 = "1"; ; str7 = "0")
      {
        localContentValues1.put(str6, str7);
        String str11 = localMBlog.rtreason;
        localContentValues1.put("rtreason", str11);
        Integer localInteger1 = Integer.valueOf(localMBlog.rtnum);
        localContentValues1.put("rtnum", localInteger1);
        Integer localInteger2 = Integer.valueOf(localMBlog.commentnum);
        localContentValues1.put("commentnum", localInteger2);
        String str12 = String.valueOf(localMBlog.time.getTime());
        localContentValues1.put("time", str12);
        String str13 = localMBlog.pic;
        localContentValues1.put("pic", str13);
        String str14 = localMBlog.src;
        localContentValues1.put("src", str14);
        String str15 = localMBlog.rtrootid;
        localContentValues1.put("rtrootid", str15);
        if (localSQLiteDatabase.insert("home_table", null, localContentValues1) != 65535L)
          break label50;
        int j = 0;
        break;
        str7 = "0";
        break label177;
      }
      Iterator localIterator2 = paramList.iterator();
      while (localIterator2.hasNext())
      {
        CommentMessage localCommentMessage = (CommentMessage)localIterator2.next();
        ContentValues localContentValues2 = new ContentValues();
        String str16 = localCommentMessage.commentid;
        localContentValues2.put("commentid", str16);
        String str17 = localCommentMessage.commentuid;
        localContentValues2.put("commentuid", str17);
        String str18 = localCommentMessage.commentnick;
        localContentValues2.put("commentnick", str18);
        String str19 = localCommentMessage.commentportrait;
        localContentValues2.put("commentportrait", str19);
        String str20 = localCommentMessage.commentcontent;
        localContentValues2.put("commentcontent", str20);
        Long localLong = Long.valueOf(localCommentMessage.commenttime.getTime());
        localContentValues2.put("commenttime", localLong);
        String str21 = localCommentMessage.mblogid;
        localContentValues2.put("mblogid", str21);
        String str22 = localCommentMessage.mbloguid;
        localContentValues2.put("mbloguid", str22);
        String str23 = localCommentMessage.mblognick;
        localContentValues2.put("mblognick", str23);
        String str24 = localCommentMessage.mblogcontent;
        localContentValues2.put("mblogcontent", str24);
        String str25 = localCommentMessage.srcid;
        localContentValues2.put("srcid", str25);
        String str26 = localCommentMessage.srcuid;
        localContentValues2.put("srcuid", str26);
        String str27 = localCommentMessage.srccontent;
        localContentValues2.put("srccontent", str27);
      }
    }
  }

  public void onCreate(SQLiteDatabase paramSQLiteDatabase)
  {
    paramSQLiteDatabase.execSQL("CREATE TABLE home_table (mblogid TEXT primary key, uid TEXT, favid TEXT, nick TEXT, portrait TEXT, vip INTEGER, content TEXT, rtrootuid TEXT, rtrootnick TEXT, rtrootvip TEXT, rtreason TEXT, rtnum INTEGER, commentnum INTEGER, time TEXT, pic TEXT, src TEXT,rtrootid TEXT)");
  }

  public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
  {
    paramSQLiteDatabase.execSQL("DROP TABLE IF EXISTS home_table");
    onCreate(paramSQLiteDatabase);
  }

  public Object select(int paramInt)
  {
    SQLiteDatabase localSQLiteDatabase = getWritableDatabase();
    Object localObject1;
    Object localObject3;
    int j;
    switch (paramInt)
    {
    case 1:
    case 2:
    default:
      localObject1 = null;
      return localObject1;
    case 0:
      ArrayList localArrayList1 = new ArrayList();
      localCursor = localSQLiteDatabase.query("home_table", null, null, null, null, null, null);
      boolean bool1 = localCursor.moveToFirst();
      while (true)
      {
        if (localCursor.isAfterLast())
        {
          localObject1 = localArrayList1;
          break;
        }
        localObject3 = new MBlog();
        j = 0;
        if (localCursor.getColumnName(j).equals("uid"))
        {
          String str1 = localCursor.getString(j);
          ((MBlog)localObject3).uid = str1;
          if (((MBlog)localObject3).uid.equals(""))
          {
            localObject1 = null;
            break;
          }
        }
        else
        {
          if (!localCursor.getColumnName(j).equals("favid"))
            break label198;
          String str2 = localCursor.getString(j);
          ((MBlog)localObject3).favid = str2;
        }
        label198: 
        do
          while (true)
          {
            j += 1;
            break;
            if (localCursor.getColumnName(j).equals("mblogid"))
            {
              String str3 = localCursor.getString(j);
              ((MBlog)localObject3).mblogid = str3;
              continue;
            }
            if (localCursor.getColumnName(j).equals("nick"))
            {
              String str4 = localCursor.getString(j);
              ((MBlog)localObject3).nick = str4;
              continue;
            }
            if (localCursor.getColumnName(j).equals("portrait"))
            {
              String str5 = localCursor.getString(j);
              ((MBlog)localObject3).portrait = str5;
              continue;
            }
            int i;
            if (localCursor.getColumnName(j).equals("vip"))
            {
              if (localCursor.getString(j).equals("1"));
              for (i = 1; ; i = 0)
              {
                ((MBlog)localObject3).vip = i;
                break;
              }
            }
            if (localCursor.getColumnName(j).equals("content"))
            {
              String str6 = localCursor.getString(j);
              ((MBlog)localObject3).content = str6;
              continue;
            }
            if (localCursor.getColumnName(j).equals("rtrootuid"))
            {
              String str7 = localCursor.getString(j);
              ((MBlog)localObject3).rtrootuid = str7;
              continue;
            }
            if (localCursor.getColumnName(j).equals("rtrootnick"))
            {
              String str8 = localCursor.getString(j);
              ((MBlog)localObject3).rtrootnick = str8;
              continue;
            }
            if (localCursor.getColumnName(j).equals("rtrootvip"))
            {
              if (localCursor.getString(j).equals("1"));
              for (i = 1; ; i = 0)
              {
                ((MBlog)localObject3).rtrootvip = i;
                break;
              }
            }
            if (localCursor.getColumnName(j).equals("rtreason"))
            {
              String str9 = localCursor.getString(j);
              ((MBlog)localObject3).rtreason = str9;
              continue;
            }
            if (localCursor.getColumnName(j).equals("rtnum"))
            {
              int k = localCursor.getInt(j);
              ((MBlog)localObject3).rtnum = k;
              continue;
            }
            if (localCursor.getColumnName(j).equals("commentnum"))
            {
              int m = localCursor.getInt(j);
              ((MBlog)localObject3).commentnum = m;
              continue;
            }
            if (localCursor.getColumnName(j).equals("time"))
            {
              long l1 = Long.parseLong(localCursor.getString(j));
              Date localDate1 = new Date(l1);
              ((MBlog)localObject3).time = localDate1;
              continue;
            }
            if (localCursor.getColumnName(j).equals("pic"))
            {
              String str10 = localCursor.getString(j);
              ((MBlog)localObject3).pic = str10;
              continue;
            }
            if (!localCursor.getColumnName(j).equals("src"))
              break label772;
            String str11 = localCursor.getString(j);
            ((MBlog)localObject3).src = str11;
          }
        while (!localCursor.getColumnName(j).equals("rtrootid"));
        label772: String str12 = localCursor.getString(j);
        ((MBlog)localObject3).rtrootid = str12;
        boolean bool2 = localArrayList1.add(localObject3);
        boolean bool3 = localCursor.moveToNext();
      }
    case 3:
    }
    ArrayList localArrayList2 = new ArrayList();
    Cursor localCursor = localSQLiteDatabase.query("comment_message_table", null, null, null, null, null, null);
    boolean bool4 = localCursor.moveToFirst();
    while (true)
    {
      if (localCursor.isAfterLast())
      {
        Object localObject2 = localArrayList2;
        break;
      }
      localObject3 = new CommentMessage();
      j = 0;
      String str13 = localCursor.getColumnName(j);
      if (str13.equals("commentid"))
      {
        String str14 = localCursor.getString(j);
        ((CommentMessage)localObject3).commentid = str14;
      }
      label1264: 
      do
        while (true)
        {
          j += 1;
          break;
          if (str13.equals("commentuid"))
          {
            String str15 = localCursor.getString(j);
            ((CommentMessage)localObject3).commentuid = str15;
            continue;
          }
          if (str13.equals("commentnick"))
          {
            String str16 = localCursor.getString(j);
            ((CommentMessage)localObject3).commentnick = str16;
            continue;
          }
          if (str13.equals("commentportrait"))
          {
            String str17 = localCursor.getString(j);
            ((CommentMessage)localObject3).commentportrait = str17;
            continue;
          }
          if (str13.equals("commentcontent"))
          {
            String str18 = localCursor.getString(j);
            ((CommentMessage)localObject3).commentcontent = str18;
            continue;
          }
          if (str13.equals("commenttime"))
          {
            long l2 = localCursor.getInt(j) * 1000;
            Date localDate2 = new Date(l2);
            ((CommentMessage)localObject3).commenttime = localDate2;
            continue;
          }
          if (str13.equals("mblogid"))
          {
            String str19 = localCursor.getString(j);
            ((CommentMessage)localObject3).mblogid = str19;
            continue;
          }
          if (str13.equals("mbloguid"))
          {
            String str20 = localCursor.getString(j);
            ((CommentMessage)localObject3).mbloguid = str20;
            continue;
          }
          if (str13.equals("mblognick"))
          {
            String str21 = localCursor.getString(j);
            ((CommentMessage)localObject3).mblognick = str21;
            continue;
          }
          if (str13.equals("srcid"))
          {
            String str22 = localCursor.getString(j);
            ((CommentMessage)localObject3).srcid = str22;
            continue;
          }
          if (!str13.equals("srcuid"))
            break label1264;
          String str23 = localCursor.getString(j);
          ((CommentMessage)localObject3).srcuid = str23;
        }
      while (!str13.equals("srccontent"));
      String str24 = localCursor.getString(j);
      ((CommentMessage)localObject3).srccontent = str24;
      boolean bool5 = localArrayList2.add(localObject3);
      boolean bool6 = localCursor.moveToNext();
    }
  }

  public boolean update(Object paramObject, int paramInt1, int paramInt2, int paramInt3)
  {
    SQLiteDatabase localSQLiteDatabase = getWritableDatabase();
    int i;
    switch (paramInt3)
    {
    case 1:
    case 2:
    default:
      i = 0;
    case 0:
    case 3:
    }
    while (true)
    {
      return i;
      MBlog localMBlog = (MBlog)paramObject;
      String[] arrayOfString1 = new String[1];
      String str1 = localMBlog.mblogid;
      arrayOfString1[0] = str1;
      ContentValues localContentValues1 = new ContentValues();
      Integer localInteger1 = Integer.valueOf(paramInt1);
      localContentValues1.put("rtnum", localInteger1);
      Integer localInteger2 = Integer.valueOf(paramInt2);
      localContentValues1.put("commentnum", localInteger2);
      int j = localSQLiteDatabase.update("home_table", localContentValues1, "mblogid =? ", arrayOfString1);
      i = 1;
      continue;
      CommentMessage localCommentMessage = (CommentMessage)paramObject;
      String[] arrayOfString2 = new String[1];
      String str2 = localCommentMessage.commentid;
      arrayOfString2[0] = str2;
      ContentValues localContentValues2 = new ContentValues();
      String str3 = localCommentMessage.commentid;
      localContentValues2.put("commentid", str3);
      String str4 = localCommentMessage.commentuid;
      localContentValues2.put("commentuid", str4);
      String str5 = localCommentMessage.commentnick;
      localContentValues2.put("commentnick", str5);
      String str6 = localCommentMessage.commentportrait;
      localContentValues2.put("commentportrait", str6);
      String str7 = localCommentMessage.commentcontent;
      localContentValues2.put("commentcontent", str7);
      Long localLong = Long.valueOf(localCommentMessage.commenttime.getTime());
      localContentValues2.put("commenttime", localLong);
      String str8 = localCommentMessage.mblogid;
      localContentValues2.put("mblogid", str8);
      String str9 = localCommentMessage.mbloguid;
      localContentValues2.put("mbloguid", str9);
      String str10 = localCommentMessage.mblognick;
      localContentValues2.put("mblognick", str10);
      String str11 = localCommentMessage.mblogcontent;
      localContentValues2.put("mblogcontent", str11);
      String str12 = localCommentMessage.srcid;
      localContentValues2.put("srcid", str12);
      String str13 = localCommentMessage.srcuid;
      localContentValues2.put("srcuid", str13);
      String str14 = localCommentMessage.srccontent;
      localContentValues2.put("srccontent", str14);
      int k = localSQLiteDatabase.update("comment_message_table", localContentValues2, "commentid =? ", arrayOfString2);
      i = 1;
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.SinaWeiboDB
 * JD-Core Version:    0.6.0
 */